package com.gcd.gym.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gcd.gym.mapper.CourseMapper;
import com.gcd.gym.model.searchModel.CourseSearchModel;
import com.gcd.gym.model.searchModel.ReserveSearchModel;
import com.gcd.gym.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    private CourseMapper courseMapper;

    @Autowired
    public void setCourseMapper(CourseMapper courseMapper) {
        this.courseMapper = courseMapper;
    }

    @Override
    public Page<CourseSearchModel> findCourse(Page<CourseSearchModel> page, CourseSearchModel course) {
        return courseMapper.findCourse(page,course);
    }

    @Override
    public int deleteCourseById(List<Integer> ids) {
        if (ids != null && !ids.isEmpty()) {
            return courseMapper.deleteCourseById(ids);
        }
        else {
            return 0;
        }
    }

    @Override
    public boolean addCourse(CourseSearchModel course) {
        return courseMapper.addCourse(course)==1;
    }

    @Override
    public boolean updateCourse(CourseSearchModel course) {
        return courseMapper.updateCourse(course)==1;
    }

    @Override
    public List<ReserveSearchModel> memberOfCourse(Integer id) {
        return courseMapper.memberOfCourse(id);
    }

    //签到
    @Override
    public boolean checkIn(ReserveSearchModel  reserve) {
        return courseMapper.checkIn(reserve)==1;
    }

    @Override
    public boolean markAbsent(ReserveSearchModel  reserve) {
        return courseMapper.markAbsent(reserve)==1;
    }
}
